package com.margo.project.zipkin.entrance;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.margo.project.zipkin.httpclient.MargoHttpClientService;
import com.margo.project.zipkin.mysql.mybatis.service.ExternalUserService;

@Controller
@RequestMapping("/zipkin")
public class MargoEntranceController {
	
	@Autowired
	private MargoHttpClientService margoHttpClientService;
	
	@Autowired
	private ExternalUserService externalUserService;

	
	/**
	 * localhost:9412/zipkin/springmvc
	 * @param orderId
	 * @return
	 * @throws InterruptedException
	 */
    @RequestMapping("/springmvc")
    @ResponseBody
    public String springMvcEntrance() throws InterruptedException {
		Thread.sleep(2000);
		margoHttpClientService.httpRequest();
		externalUserService.read("15802712345", "422326199012345678");
        return "helloWorld";
    }
    
	/**
	 * localhost:9412/zipkin/sentinel
	 * @param orderId
	 * @return
	 * @throws InterruptedException
	 */
    @RequestMapping("/sentinel")
    @ResponseBody
    public String sentinelEntrance() throws InterruptedException {
		Thread.sleep(2000);
		margoHttpClientService.sentinelRequest();
        return "helloWorld";
    }
}
